package b2.scene.fight.skills
{
	import b2.scene.fight.PlayState;
	import b2.scene.fight.TankSprite;
	
	import org.flixel.FlxG;
	
	public class BasicSkill
	{
		protected var tankId:int;
		protected var side:int;
		protected var skillArgs:Object;
		protected var level:int;
		
		public var coolDown:int;
		
		public function BasicSkill(tankId:int, side:int, level:int, skillArgs:Object)
		{
			this.tankId = tankId;
			this.side = side;
			this.skillArgs = skillArgs;
			this.level = level;
			this.coolDown = 0;
		}

		//判断技能释放时机
		public virtual function checkSkillTriggerPremise(x:int, y:int, direction:int):Boolean
		{
			if (coolDown > 0)
				return false;
			return true;
		}

		//释放技能
		public virtual function discharge(x:int, y:int, direction:int):void
		{
			coolDown = skillArgs.cooldown;
		}

		public function onTimer():void
		{
			coolDown--;
		}
		
		protected function getPlayState():PlayState
		{
			return FlxG.state as PlayState;
		}
		
		protected function getOwner():TankSprite
		{
			return getPlayState().tanks[tankId];
		}
	}
}